﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/OneCol.Master" Title="Password Question" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="content" ContentPlaceHolderID="Col1" runat="server">

	<h2>Forgot Your Password?</h2>

	<% if( ( TempData["ErrorMessage"] ?? ViewData["ErrorMessage"] ) != null ){ %>
	<p class="MvcMembershipError"><% =(string)TempData["ErrorMessage"] ?? (string)ViewData["ErrorMessage"]%></p>
	<% } %>

	<% using (Html.Form("FormsAuthentication", ViewData["PostbackAction"].ToString())) { %>
	<fieldset class="MvcMembership">
		<legend>Password Question</legend>
		<div><label for="userName">User Name:</label> <% =ViewData["UserName"] %></div>
		<div><label>Question:</label> <% =ViewData["PasswordQuestion"] %></div>
		<div><label for="passwordAnswer">Answer:</label> <% =Html.TextBox( "passwordAnswer" )%></div>
		<div><% =Html.SubmitButton( "submit", "Answer Password Question", new { onclick = "return starterKit_mvc_membership_validatePasswordQuestion();" } )%></div>
		<% =Html.Hidden( "userName", ViewData["UserName"] ) %>
	</fieldset>
	<% } %>

	<script type="text/javascript">
	/* <![CDATA[ */

		function starterKit_mvc_membership_validatePasswordQuestion()
		{

			var userName = document.getElementById('userName').value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
			if( userName.length < 1 )
			{
				alert( 'Please enter your user name.' );
				document.getElementById('userName').focus();
				return false;
			}

			var passwordAnswer = document.getElementById('passwordAnswer').value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
			if( passwordAnswer.length < 1 )
			{
				alert( 'Please enter the answer to your password question.' );
				document.getElementById('passwordAnswer').focus();
				return false;
			}

			return true;

		}

	/* ]]> */
	</script>

</asp:Content>
